# =======================================================================
# doxygen support
# =======================================================================
  
find_package(Doxygen)
  if(NOT DOXYGEN_EXECUTABLE)
    message(STATUS "WARNING: Doxygen not found so documentation not generated.")
 endif(NOT DOXYGEN_EXECUTABLE)
if(DOXYGEN_EXECUTABLE)
  
  # N.B. Both the following custom rules assume the doc directory exists
  # at make time, and the following install(DIRECTORY... must have doc exist
  # at cmake time.  Therefore, create the doc directory at CMake time.
  # (Linux experimentation indicates this is a no-op if the empty or
  # non-empty directory already exists.)
  file(MAKE_DIRECTORY ${CMAKE_SOURCE_DIR}/doc)

  # The initial rm command gets rid of everything previously built by this
  # custom command.
#  add_custom_command(
#  OUTPUT ${CMAKE_SOURCE_DIR}/doc/html/index.html
#  COMMAND rm -rf ${CMAKE_SOURCE_DIR}/doc/html
#  #COMMAND mkdir ${CMAKE_SOURCE_DIR}/doc
#  COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_SOURCE_DIR}/doxygen.conf.in
#  DEPENDS ${CMAKE_SOURCE_DIR}/doxygen.conf.in
#  WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
##  )

  # The initial rm command gets rid of everything previously built by this
  # custom command.
 # add_custom_command(
 # OUTPUT ${CMAKE_SOURCE_DIR}/doc/developer/html/index.html
 # COMMAND rm -rf ${CMAKE_SOURCE_DIR}/doc/developer
 # COMMAND mkdir ${CMAKE_SOURCE_DIR}/doc/developer
 ## COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_SOURCE_DIR}/Doxyfile.developer
 # DEPENDS ${CMAKE_SOURCE_DIR}/Doxyfile.developer
 ## WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
 # )
 add_custom_target (api-docs doxygen 
   ${CMAKE_SOURCE_DIR}/doxygen.conf.in
   WORKING_DIRECTORY 
   ${PROJ_SOURCE_DIR} 
   COMMENT "Generating documentation")
#  add_custom_target(
#  doc ALL
#  DEPENDS
#  ${CMAKE_SOURCE_DIR}/doc/html/index.html
#  #${CMAKE_SOURCE_DIR}/doc/developer/html/index.html
#  )
  
  # Install the documentation generated at "make" time.
#  install(DIRECTORY ${CMAKE_SOURCE_DIR}/doc/ DESTINATION ${docdir}/html)

endif(DOXYGEN_EXECUTABLE)

##############################################
